package pojo.vo;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import pojo.ErrorCodeEnum;

import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageResult<T> {
    private Integer code;
    private String message;
    // 当前页的数据
    private List<T> rows;
    // 总数
    private Long total;

    public static <T> PageResult<T> success(Page<T> page) {
        return new PageResult<>(ErrorCodeEnum.SUCESS.getCode(), ErrorCodeEnum.SUCESS.getMessage(), page.getRecords(), page.getTotal());
    }
    public static <T> PageResult<T> success(List<T> list,Long total) {
        return new PageResult<>(ErrorCodeEnum.SUCESS.getCode(), ErrorCodeEnum.SUCESS.getMessage(), list, total);
    }

}
